import 'package:dynamic_forms/dynamic_forms.dart';

import 'form_field_group.dart';

class FormFieldGroupParser extends ElementParser<DyFormFieldGroup> {
  @override
  String get name => "formFieldGroup";

  @override
  DyFormFieldGroup parse(
      ParserNode parserNode, FormElement parent, ElementParserFunction parser) {
    var formFieldGroup = DyFormFieldGroup();
    formFieldGroup.fillFormFieldGroup(
      id: parserNode.getPlainStringValue("id"),
      isVisible: parserNode.getIsVisible(),
      parent: parserNode.getParentValue(parent),
      children: parserNode.getChildren<FormElement>(
          parent: formFieldGroup,
          parser: parser,
          childrenPropertyName: DyFormFieldGroup.childrenPropertyName,
          isContentProperty: true),
      attribute:
          parserNode.getStringValue(DyFormFieldGroup.attributePropertyName),
    );
    return formFieldGroup;
  }
}
